//
//  TZTabbarController.m
//  BSBDJ
//
//  Created by user on 16/5/23.
//  Copyright © 2016年 Burning. All rights reserved.
//

#import "TZTabbarController.h"
#import "TZNavigationController.h"
#import "TZMeVc.h"
#import "TZNewVc.h"
#import "TZFriendVc.h"
#import "TZEssenceVc.h"
#import "TZToolbar.h"
@interface TZTabbarController ()

@end

@implementation TZTabbarController

+ (void)initialize
{
    UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
//    
//    [item setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor lightGrayColor]} forState:0];
    [item setTitleTextAttributes:@{NSForegroundColorAttributeName :[UIColor darkGrayColor]} forState:UIControlStateSelected];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addChildVc];
}



- (void)addChildVc{
    
    
    TZEssenceVc *essenceVc = [TZEssenceVc new];
    [self setupChildVc:essenceVc image:[UIImage imageNamed:@"tabBar_essence_icon"] seletedImage:[UIImage imageNamed:@"tabBar_essence_click_icon"] title:@"精髓"];
    
    TZNewVc *newVc = [TZNewVc new];
    [self setupChildVc:newVc image:[UIImage imageNamed:@"tabBar_new_icon"] seletedImage:[UIImage imageNamed:@"tabBar_new_click_icon"] title:@"新帖"];
    
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"TZFriendVc" bundle:nil];
    TZFriendVc *friendVc = [sb instantiateInitialViewController];
    [self setupChildVc:friendVc image:[UIImage imageNamed:@"tabBar_friendTrends_icon"] seletedImage:[UIImage imageNamed:@"tabBar_friendTrends_click_icon"] title:@"朋友圈"];
    
    TZMeVc *meVc = [TZMeVc new];
    [self setupChildVc:meVc image:[UIImage imageNamed:@"tabBar_me_icon"] seletedImage:[UIImage imageNamed:@"tabBar_me_click_icon"] title:@"我的"];
    
    TZToolbar *toolBar = [[TZToolbar alloc] init];
    [self setValue:toolBar forKeyPath:@"tabBar"];
    
}

- (void)setupChildVc:(UIViewController*)vc
              image :(UIImage*)image
       seletedImage :(UIImage*)seletedImgae
               title:(NSString*)title{
    vc.navigationItem.title = title;
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = image;
    vc.tabBarItem.selectedImage = seletedImgae;
    TZNavigationController *nav = [[TZNavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
}

@end
